#include "header.hpp"
using namespace std;

void test5(){
class Entity{
public:
    Entity(){
        cout << "Created Entity" << endl;
    }

    ~Entity(){
        cout << "Destroyed Entity" << endl;
    }

    void print(){
        cout << "Print" << endl;
    }
};

//Scope
    {
        shared_ptr<Entity> e0;
        {
            //unique_ptr will destroy when program reach the end of the scope
            //unique_ptr has object semantic:
            //its copy constructor and copy assignment operator are deleted
            unique_ptr<Entity> entity(new Entity());
            entity->print();

            //shared_ptr & weak_ptr
            shared_ptr<Entity> sharedEntity(new Entity());
            weak_ptr<Entity> weakEntity = sharedEntity;
            e0 = sharedEntity;

            cout << e0.use_count() << endl;
        }
        cout << e0.use_count() << endl;
    }
//end of scope
}
